//
//  VideoViewController.m
//  Product_NEWS
//
//  Created by dllo on 15/12/28.
//  Copyright © 2015年 FCH. All rights reserved.
//

#import "VideoViewController.h"
#import "TabbarButton.h"
#import "VideoData.h"
#import "VideoViewCell.h"
#import "NightModeHandle.h"
#import "ClassViewController.h"
#import "DetailViewController.h"
#import "UMSocialSnsPlatformManager.h"
#import "UMSocialSnsService.h"

//音频视频
#import <AVFoundation/AVFoundation.h>

@interface VideoViewController ()<UITableViewDataSource,UITableViewDelegate,VideoPlayDelegate>
@property(nonatomic,retain)NSMutableArray *videoArray;
@property(nonatomic,retain)UITableView *myTableView;
@property (nonatomic , retain) TabbarButton *btn;
@property(nonatomic,retain)VideoViewCell *cell;
@property(nonatomic,assign)int page;
@property(nonatomic,assign)BOOL isUpLoading;

// 设置播放器播放项目的类， 播放视频资源
@property (nonatomic, retain) AVPlayerItem *playerItem;
// 视频播放器对象
@property (nonatomic, retain) AVPlayer *player;
//  设置承载显示视频播放器的类
@property (nonatomic, retain) AVPlayerLayer *playerLayer;
@property (nonatomic, retain) UIView *btnView;
@property (nonatomic ,retain) UIButton *playButton;
@property (nonatomic, retain) UIView *playerView;
@property (nonatomic, retain) UISlider *slider;

@property (nonatomic, assign) CGFloat totalDuraion; // 记录总时长

@property (nonatomic ,assign) BOOL isPlaying; // 记录播放状态

@property (nonatomic, retain) UILabel *leftTimeLabel;
@property (nonatomic, retain) UILabel *rightTimeLabel;
@property (nonatomic, copy) NSString *currentString;

@end

@implementation VideoViewController
-(void)dealloc{
    [_myTableView release];
    [_videoArray release];
    [_btn release];
   
    [_player release];
    [_playerItem release];
    [_playerLayer release];
    [super dealloc];
}


-(void)viewWillAppear:(BOOL)animated{
     self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.898 green:0.063 blue:0.000 alpha:1.000];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.videoArray = [NSMutableArray array];

    [self initUI];
    [self addFooter];
    [self addHeader];

}



-(void) initUI
{
    
    self.view.backgroundColor = [NightModeHandle shareNightModeHandle].allViewColor;

    
    self.myTableView = [[UITableView alloc]initWithFrame:CGRectMake(10 *SCREEN_WIDTH, 0, 355 * SCREEN_WIDTH, 657 * SCREEN_HEIGHT) style:UITableViewStyleGrouped];
   
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
  
    
    [self.view addSubview:self.myTableView];
    [_myTableView release];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH * 375 - 20 * SCREEN_WIDTH, 375 * SCREEN_WIDTH * 0.25)];

     UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH * 375, 10 * SCREEN_WIDTH )];
    
    [view addSubview:view1];

    
  
    
    
    
    
    
    
    NSArray *array =@[@"奇葩",@"萌物",@"美女",@"精品"];
    
    NSArray *images = @[[UIImage imageNamed:@"qipa"],
                        [UIImage imageNamed:@"mengchong"],
                        [UIImage imageNamed:@"meinv"],
                        [UIImage imageNamed:@"jingpin"]
                        ];
    
    for (int i = 0 ; i < 4; i ++) {
        TabbarButton *btn = [[TabbarButton alloc]init];
        btn.backgroundColor = [NightModeHandle shareNightModeHandle].allViewColor;

        [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        
        
        btn.frame = CGRectMake(SCREEN_WIDTH * 355 / 4 * i , 10 * SCREEN_HEIGHT, 375*SCREEN_WIDTH / 4 , view.frame.size.height-10* SCREEN_HEIGHT);
        [btn setImage:images[i] forState:UIControlStateNormal];
        [btn setTitle:array[i] forState:UIControlStateNormal];
        btn.titleLabel.font = [UIFont systemFontOfSize:15*SCREEN_WIDTH];
        btn.titleLabel.textColor = [NightModeHandle shareNightModeHandle].titleColor;
        btn.tag = i;
        self.btn = btn;
        [view addSubview:self.btn];
        [_btn release];
    }
    UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(0, view.frame.size.height , SCREEN_WIDTH * 375, 10 * SCREEN_WIDTH )];
    view2.backgroundColor = [NightModeHandle shareNightModeHandle].allViewColor;

    [view addSubview:view2];
    
    self.myTableView.tableHeaderView = view;

}



-(void)addHeader
{
    __block VideoViewController *vc = self;
    [self.myTableView addHeaderWithCallback:^{
        
        vc.page = 1;
        vc.isUpLoading = NO;
        [vc GetPersonList:vc.page];
        
        
    }];
    
    
    //自动刷新
    [self.myTableView headerBeginRefreshing];
}

-(void)addFooter
{
    __block VideoViewController *vc = self;
    [self.myTableView addFooterWithCallback:^{
        
        vc.page ++;
        vc.isUpLoading = YES;
        [vc GetPersonList:vc.page];
    }];
}




-(void)GetPersonList:(NSInteger)nextCursor
{
    AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    
    NSString *getstr = [NSString stringWithFormat:@"http://c.m.163.com/nc/video/home/%d-10.html",self.page];
    
    [mgr GET:getstr parameters:dic success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        if (self.isUpLoading == NO) {
            //说明是下拉，就要清空数组中的数据
            [self.videoArray removeAllObjects];
        }
        NSMutableArray *allArr= [responseObject objectForKey:@"videoList"];

        
        for (NSDictionary *dic in allArr) {
            
            VideoData *videoData = [[VideoData alloc]init];
            [videoData setValuesForKeysWithDictionary:dic];
        
            videoData.Description = [dic objectForKey:@"description"];
            
            
            [self.videoArray addObject:videoData];
        }
        
        
        
//        self.page += 10;
        // 刷新表格
        [self.myTableView footerEndRefreshing];
        [self.myTableView headerEndRefreshing];
        [self.myTableView reloadData];
        
    } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) {
        [self.myTableView headerEndRefreshing];
        [self.myTableView footerEndRefreshing];
        MBProgressHUD *mb = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        mb.mode = MBProgressHUDModeText;
        mb.labelText = @"网络不给力";
        [mb hide:YES afterDelay:0.5];
    }];
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.videoArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    VideoViewCell *cell = [VideoViewCell cellWithTableView:tableView];
    cell.myDelegate = self;
    VideoData *video = self.videoArray [indexPath.row];
    cell.videoData = video;
    cell.indexPath = indexPath;
    
    return cell;
}

//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
//    return 10;
//}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 350*SCREEN_HEIGHT;
}



-(void)btnAction:(TabbarButton *)btn
{
    NSArray *arr = @[@"VAP4BFE3U",
                     @"VAP4BFR16",
                     @"VAP4BG6DL",
                     @"VAP4BGTVD"];
    for (int i = 0; i < 4; i++) {
        if (btn.tag == i) {
            ClassViewController *classVC = [[ClassViewController alloc]init];
            classVC.url = arr[i];
            classVC.title = btn.titleLabel.text;
            [self.navigationController pushViewController:classVC animated:YES];
        }
    }
}





#pragma mark -  点击
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    VideoData *videoData = self.videoArray[indexPath.row];
    
    DetailViewController *detailVC = [[DetailViewController alloc]init];
    
    detailVC.model = videoData;


    [self.navigationController pushViewController:detailVC animated:YES];
    self.hidesBottomBarWhenPushed = NO;
    
  

    
}




#pragma  mrak  - 协议方法实现



-(void)videoPlay:(NSIndexPath *)indexPath
{
    
    VideoData *model = self.videoArray[indexPath.row];
    [self playWithUrl:model.mp4_url];
    self.playerView.frame = CGRectMake(0, 100 * SCREEN_HEIGHT + 348 * SCREEN_HEIGHT * indexPath.row  , 355 * SCREEN_WIDTH,375 * SCREEN_WIDTH * 0.5 );
    self.playerLayer.frame = self.playerView.bounds;
    
    [self showPlayerProgress];
    [self.player play];
 
}

-(void)VideoCommon:(NSIndexPath *)indexPath{
    VideoData *model = self.videoArray[indexPath.row];
    
    DetailViewController *detail = [[DetailViewController alloc]init];
    detail.model = model;
    [self.navigationController pushViewController:detail animated:YES];

}

-(void)shareVideo:(NSIndexPath *)indexPath
{
    UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];
    /**
     Sns平台类，用`platformName`作为标识，指定显示名称、显示的图片，点击之后的响应。
     */
    snsPlatform.displayName = @"新浪";
    snsPlatform.loginName = @"网易";
    
    
    UMSocialSnsPlatform *snsPlatform2 = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToTencent];
    snsPlatform2.displayName = @"腾讯微博";
    
    
    
    //分享第二步
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"558936d367e58eb81b001298"
                                      shareText:@"你要分享的文字"
                                     shareImage:[UIImage imageNamed:@"Icon-29.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren,nil]
                                       delegate:nil];
    
         }




#pragma 设置视频相关

- (void)playWithUrl:(NSString *)urlString{
  
        NSURL *url = [NSURL URLWithString:urlString];
        self.playerItem = [AVPlayerItem playerItemWithURL:url];
        if (_player == nil) {
            
            self.player = [AVPlayer playerWithPlayerItem:self.playerItem];
            self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
            self.playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
            self.playerLayer.frame = self.playerView.bounds;
            [self.playerView.layer addSublayer:self.playerLayer];
            
            
            self.btnView = [[UIView alloc] initWithFrame:CGRectMake(0,self.playerView.frame.size.height - 30 * SCREEN_HEIGHT + 186 * SCREEN_HEIGHT, 375 * SCREEN_WIDTH, 30 * SCREEN_HEIGHT)];
            self.btnView.backgroundColor = [UIColor blackColor];
            self.btnView.alpha = 0.5;
            [self.playerView addSubview:self.btnView];
            [_btnView release];
            
            self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
            self.playButton.frame = CGRectMake(5*SCREEN_WIDTH, 5*SCREEN_HEIGHT, 15*SCREEN_WIDTH, 15 *SCREEN_HEIGHT);
            [self.playButton setImage:[UIImage imageNamed:@"iconfont-zanting.png"] forState:UIControlStateNormal];
            [self.playButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [self.btnView addSubview:self.playButton];
            [_playButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
            
            self.slider = [[UISlider alloc] initWithFrame:CGRectMake(90*SCREEN_WIDTH, 3 * SCREEN_HEIGHT, 200*SCREEN_WIDTH, 20 *SCREEN_HEIGHT)];
            self.slider.value = 0;
            self.slider.maximumValue = 1;
            self.slider.minimumValue = 0;
            
            
            self.leftTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(40*SCREEN_WIDTH, -10 * SCREEN_HEIGHT, 50*SCREEN_WIDTH, 50 *SCREEN_HEIGHT)];
            self.leftTimeLabel.font = [UIFont systemFontOfSize:13*SCREEN_WIDTH];
            self.leftTimeLabel.textColor = [UIColor whiteColor];
            self.leftTimeLabel.text = @"00:00";
            [self.btnView addSubview:self.leftTimeLabel];
            
            
            self.rightTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(300*SCREEN_WIDTH, -10 * SCREEN_HEIGHT, 50*SCREEN_WIDTH, 50 * SCREEN_HEIGHT)];
            self.rightTimeLabel.textColor = [UIColor whiteColor];
            self.rightTimeLabel.text = @"00:00";
            self.rightTimeLabel.font = [UIFont systemFontOfSize:13*SCREEN_WIDTH];
            [self.btnView addSubview:self.rightTimeLabel];
            
            
            [self.btnView addSubview:self.slider];
            [self.slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
            [_slider release];
            
            self.isPlaying = NO;
            
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
           
            [self.playerView addGestureRecognizer:tap];
            
            
        }else{
            
            [self.player replaceCurrentItemWithPlayerItem:self.playerItem];
        }
//    }
    self.isPlaying = YES;
    
}

//视频左下方播放按钮
- (void)buttonAction:(UIButton *)button{
    
    if (self.isPlaying == NO) {
        [self.player play];
        [self.playButton setImage:[UIImage imageNamed:@"iconfont-zanting.png"] forState:UIControlStateNormal];
        
    }else{
        
        [self.player pause];
        [self.playButton setImage:[UIImage imageNamed:@"iconfont-bofangqibofang.png"] forState:UIControlStateNormal];
    }
    self.isPlaying = !self.isPlaying;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [UIView animateWithDuration:2 animations:^{
                
                self.btnView.alpha = 0;
            }];
            
        });
        
    });
}


//滑动条
- (void)sliderAction:(UISlider *)slider{
    
    
    double currentTime = slider.value * self.totalDuraion;
    
    CMTime time = CMTimeMake(currentTime, 1);
    
    [self.player seekToTime:time completionHandler:^(BOOL finished) {
        
        [self.player play];
        
    }];
    
    
}

- (void)showPlayerProgress{
    
    CMTime time = CMTimeMake(1, 1);
    
    
    __block VideoViewController *vc = self;
    
    [vc.player addPeriodicTimeObserverForInterval:time queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
        
        CMTime currentTime = vc.playerItem.currentTime;
        CMTime totalTime = vc.playerItem.duration;
        
        double currentT = CMTimeGetSeconds(currentTime);
        double totalT = CMTimeGetSeconds(totalTime);
        
        vc.slider.value = currentT / totalT;
        
        vc.totalDuraion = totalT;
    
        
        
        // 总时长
        CGFloat duration = CMTimeGetSeconds(self.playerItem.duration);
       
        // 当前时长
        CGFloat current = CMTimeGetSeconds(self.player.currentTime);
     

        NSString *duration1 = [NSString stringWithFormat:@"%02d:%02d", (int)duration / 60, (int) duration % 60];
        NSString *currentTime1 = [NSString stringWithFormat:@"%02d:%02d", (int) current / 60, (int) current % 60];
        
        self.leftTimeLabel.text = currentTime1;
        self.rightTimeLabel.text = duration1;

        
    }];
    
}

- (void)tapAction:(UITapGestureRecognizer *)tap{
    
    
    if (self.btn.alpha == 1) {
        [UIView animateWithDuration:1 animations:^{
            
            self.btn.alpha = 0;
        }];
    }else{
        [UIView animateWithDuration:1 animations:^{
            
            self.btnView.alpha = 0;
        }];
    }
    
}




- (UIView *)playerView{
    if (nil == _playerView) {
        _playerView = [[UIView alloc] init];
        [_myTableView addSubview:self.playerView];
    }
    return _playerView;
}


-(void)viewWillDisappear:(BOOL)animated
{
  [[NSNotificationCenter defaultCenter] removeObserver:self];
    if (self.playerLayer) {
        NSLog(@"销毁了");
        [self.player pause];
        [self.playerView removeFromSuperview];
        self.player = nil;
    }
        
        

    }



//    
//    
//    NSURL *urlStr = [NSURL URLWithString:videoData.mp4_url];
//    //设置播放器对象资源
//    self.playerItem = [AVPlayerItem playerItemWithURL:urlStr];
//    
//    //创建播放器对象
//    self.player = [AVPlayer playerWithPlayerItem:self.playerItem];
//    //创建显示播放器对象
//    self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
//    self.playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
//    
//    self.playView = [[UIView alloc] initWithFrame:CGRectMake(0, 105 * SCREEN_HEIGHT + 300 * SCREEN_HEIGHT * indexPath.row  , 375 * SCREEN_WIDTH,375 * SCREEN_WIDTH * 0.5)];
//    self.playView.backgroundColor  = [UIColor colorWithWhite:0.128 alpha:0.500];
//    [self.myTableView addSubview:self.playView];
//    [self.playView.layer addSublayer:self.playerLayer];
//    self.playerLayer.frame = self.playView.bounds;
//    
//    self.btnView  = [[UIView alloc] initWithFrame:CGRectMake(0,  self.playerLayer.frame.size.height - 30 * SCREEN_HEIGHT, 375 * SCREEN_WIDTH, 30 * SCREEN_HEIGHT)];
//    self.btnView.backgroundColor = [UIColor colorWithRed:0.023 green:0.045 blue:0.101 alpha:0.500];
//    
//    [self.playView addSubview:self.btnView];
//    
//    self.playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    self.playBtn.frame = CGRectMake(0 , 0, 50 * SCREEN_WIDTH, 30 * SCREEN_HEIGHT);
//    self.playBtn.backgroundColor = [UIColor colorWithWhite:0.994 alpha:0.500];
//  
//    [self.btnView addSubview:self.playBtn];
//    
//    [self.playBtn addTarget:self action:@selector(playBtnAction:) forControlEvents:UIControlEventTouchUpInside];
//   
//   
//    
//  
//    
//    
//    self.slider = [[UISlider alloc] initWithFrame:CGRectMake(50 * SCREEN_WIDTH, 0, 275 * SCREEN_WIDTH, 30 * SCREEN_HEIGHT)];
//   
//    self.slider.maximumValue = 1;
//    self.slider.minimumValue = 0;
//    [self.btnView addSubview:self.slider];
//    
//    [self.slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
//    //    添加播放进度
//    [self showPalyerProgress];
//    
//    //    添加轻拍手势
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
//    [self.playView addGestureRecognizer:tap];
//    
//    //添加观察屏幕旋转的通知
//    //    UIApplicationDidChangeStatusBarFrameNotification   状态栏的变化
//    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeAction:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
//    
//    
//
   
 


//-(void)changeAction:(NSNotification *)notification{
//    NSLog(@"屏幕旋转了");
//    
//    
//    //状态栏对象
//    UIInterfaceOrientation status = [[UIApplication sharedApplication]statusBarOrientation];
//    
//    if (status == UIInterfaceOrientationLandscapeRight) {
//        NSLog(@"横屏");
//    }else if (status == UIInterfaceOrientationLandscapeLeft){
//        
//        
//        
//        NSLog(@"横屏2");
//    }else if (status ==UIInterfaceOrientationPortrait){
//        NSLog(@"竖屏");
//    }
//}


//-(void)tapAction:(UITapGestureRecognizer *)tap{
//    if (self.btnView.alpha == 0) {
//        [UIView animateWithDuration:1 animations:^{
//            
//            self.btnView.alpha = 1;
//            
//        }];
//    }else{
//        [UIView animateWithDuration:1 animations:^{
//            
//            self.btnView.alpha =0;
//            
//        }];
//    }
//}

//-(void)sliderAction:(UISlider *)slider{
//    //     当前时间 = 滑动位置 * 总时长
//    double currentTime = slider.value * self.totalDuraion;
//    //    转成播放器的时间
//    CMTime time = CMTimeMake(currentTime, 1);
//    //    调整播放器的播放进度
//    [self.player seekToTime:time completionHandler:^(BOOL finished) {
//        //        每次调整完过后让其重新播放
//        [self.player play];
//        
//        
//    }];
//    
//    
//    
//}

//-(void)showPalyerProgress{
//    
//    //     设置播放器 每秒 执行的方法， 捕获到播放器每秒触发的事件
//    //    该block 块是播放器每秒都要执行的
//    //    参数1 ： 创建CMTime 对象， 设置每秒执行一次
//    //    参数2 ： 设置线程
//    CMTime time = CMTimeMake(1, 1);
//    
//    __block VideoViewController *vc = self;
//    
//    [vc.player addPeriodicTimeObserverForInterval:time queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
//        NSLog(@"每秒钟执行一次");
//        //        获取当前时长
//        CMTime currentTime = self.playerItem.currentTime;
//        CMTime totalTime = self.playerItem.duration;
//        
//        double currentT =  CMTimeGetSeconds(currentTime);
//        double totalT = CMTimeGetSeconds(totalTime);
//        
//        self.slider.value = currentT/ totalT;
//        
//        //    保存总时长
//        self.totalDuraion = totalT;
//        
//    }];
//}
//
//-(void)playBtnAction:(UIButton *)btn{
//    
//    if (self.isPlaying == NO) {
//        
//        [self.player play];
//        [self.playBtn setImage:[UIImage imageNamed:@"videoPuse"] forState:UIControlStateNormal];
//        
//    }else{
//        
//        [self.player pause];
//        [self.playBtn setImage:[UIImage imageNamed:@"videoplay"] forState:UIControlStateNormal];
//    }
//    
//    self.isPlaying = !self.isPlaying;
//    
//    
//    // dispatch_once  只走一次
//    static dispatch_once_t onceToken;
//    dispatch_once(&onceToken, ^{
//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//            
//            [UIView animateWithDuration:2 animations:^{
//                
//                self.btnView.alpha = 0;
//                
//            }];
//            
//        });
//        
//    });
//    
//    
//}
//
//-(void)viewWillDisappear:(BOOL)animated
//{
//    [[NSNotificationCenter defaultCenter] removeObserver:self];
//    if (self.playerLayer) {
//        NSLog(@"销毁了");
//        [self.player pause];
//        [self.playView removeFromSuperview];
//        self.player = nil;
//    }

//}












- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
